var $table = $("#table")
$(function () {
    var options = {
        url: contextPath + 'category/list', //这里要去掉前面的斜杠
        idField: "id",
        parentIdField: "pid",
        treeShowField: "name",
        columns: [
            {
                title: '序号', width: 20, formatter: function (value, row, index) {
                    return index + 1;
                }
            },
            {title: 'id', visible: false},
            {title: '文章类型名', field: 'name', width: '200px'},
            {title: '类型介绍', field: 'description', width: '200px'},
            {title: '排序', field: 'sort', width: '200px'},
            {title: '是否可用', field: 'status', width: '200px'},
            {title: '图标', field: 'icon', width: '100px', formatter: iconFormatter},
            {title: '操作', visible: false,field:'action', width: '100px',formatter:$.operationFormatter},
        ]
    };
    $.treeTable(options);
});

function iconFormatter(value, row, index) {
    return '<span class = "'+value+'"></span>'
}